﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace pigs
{
    public class Scenery : pigs.DynamicObject
    {
        //is the scenery at the top of the page
        public Boolean top;

        /// <summary>
        /// create a scenery object
        /// </summary>
        /// <param name="texture">the image for the scenery</param>
        /// <param name="position">where it's located</param>
        public Scenery(Texture2D texture, Vector2 position)
            : base(texture, position)
        {
        }

        /// <summary>
        /// initialize the scenery object
        /// </summary>
        /// <param name="sp">speed that it should move at</param>
        /// <param name="collidable">can we collide with it</param>
        public void initialize(float sp, Boolean pos)
        {
            this.speed = sp;
            this.top = pos;

            //get the color data from the texture
            colorMap = new Color[texture.Width * texture.Height];
            texture.GetData(colorMap);

            rectangle = new Rectangle((int)this.position.X, (int)this.position.Y, this.texture.Width, this.texture.Height);
        }
        
        /// <summary>
        /// update the location of the object
        /// </summary>
        public void Update()
        {
            rectangle = new Rectangle((int)this.position.X, (int)this.position.Y, this.texture.Width, this.texture.Height);
            this.position.X += speed;
        }

        /// <summary>
        /// draw the object
        /// </summary>
        /// <param name="spriteBatch">spritebach in use by the game</param>
        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(texture, position, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
        }
    }
}
